package com.wx.wheelview.demo;

import com.wx.wheelview.common.WheelData;

import org.junit.Test;

import java.util.HashMap;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
 * MainAbilityTest
 *
 * @since 2021.07.15
 */
public class MainAbilityTest {
    /**
     * test createMainDatas
     */
    @Test
    public void createMainDatas() {
        com.wx.wheelview.demo.MainAbility mainAbility = new MainAbility();
        List<String> list = mainAbility.createMainDatas();
        assertEquals(3, list.size());
    }

    /**
     * test createSubDatas
     */
    @Test
    public void createSubDatas() {
        com.wx.wheelview.demo.MainAbility mainAbility = new MainAbility();
        HashMap<String, List<String>> maps = mainAbility.createSubDatas();
        String mainStr = "黑龙江";
        String[] subArr = {
                "哈尔滨",
                "齐齐哈尔",
                "大庆"
        };
        List<String> subList = maps.get(mainStr);
        assertEquals(3, subList.size());
        for (int i = 0; i < subArr.length; i++) {
            assertEquals(subArr[i], subList.get(i));
        }
    }

    /**
     * test createChildDatas
     */
    @Test
    public void createChildDatas() {
        com.wx.wheelview.demo.MainAbility mainAbility = new MainAbility();
        HashMap<String, List<String>> maps = mainAbility.createChildDatas();
        String subStr = "哈尔滨";
        String[] childArr = {
                "道里区",
                "道外区",
                "南岗区",
                "香坊区"
        };
        List<String> childList = maps.get(subStr);
        assertEquals(4, childList.size());
        for (int i = 0; i < childArr.length; i++) {
            assertEquals(childArr[i], childList.get(i));
        }
    }

    /**
     * test createHours
     */
    @Test
    public void createHours() {
        com.wx.wheelview.demo.MainAbility mainAbility = new MainAbility();
        List<String> list = mainAbility.createHours();
        assertEquals(24, list.size());
        assertEquals("00", list.get(0));
        assertEquals("23", list.get(23));
    }

    /**
     * test createMinutes
     */
    @Test
    public void createMinutes() {
        com.wx.wheelview.demo.MainAbility mainAbility = new MainAbility();
        List<String> list = mainAbility.createMinutes();
        assertEquals(60, list.size());
        assertEquals("00", list.get(0));
        assertEquals("59", list.get(59));
    }

    /**
     * test createArrays
     */
    @Test
    public void createArrays() {
        com.wx.wheelview.demo.MainAbility mainAbility = new MainAbility();
        List<String> list = mainAbility.createArrays();
        assertEquals(20, list.size());
        for (int i = 0; i < list.size(); i++) {
            assertEquals("item" + i, list.get(i));
        }
    }

    /**
     * test createDatas
     */
    @Test
    public void createDatas() {
        com.wx.wheelview.demo.MainAbility mainAbility = new MainAbility();
        List<WheelData> list = mainAbility.createDatas();
        assertEquals(20, list.size());
        WheelData item;
        for (int i = 0; i < list.size(); i++) {
            item = list.get(i);
            assertEquals((i < 10) ? ("0" + i) : ("" + i), item.getName());
        }
    }
}